﻿@{
    ViewBag.Title = "";
}
@model DTcms.Model.plugin_link
<form id="form1" class="layui-form" url="LinkSave?action=@ViewBag.action&id=@ViewBag.id">
    @Html.AntiForgeryToken()
    <!--导航栏-->
    <div class="pageheader">
        <div class="page-bar">
            <ul class="page-breadcrumb">
                <li><a href="javascript:history.back(-1);" class="back"><i class="fa fa-mail-reply-all"></i> 返回上一页</a></li>
                <li><a href="javascript:;"><i class="iconfont icon-home1"></i> 首页</a> </li>
                <li><a href="javascript:;">插件管理</a> </li>
                <li><a href="../link/link_list">友情链接</a> </li>
                <li><a href="javascript:;">编辑链接</a> </li>
            </ul>
        </div>
    </div>
    <!--/导航栏-->
    <!--内容-->
    <div class="layui-fluid">
        <div class="layui-tab layui-tab-card">
            <ul class="layui-tab-title" id="floatHead">
                <li class="layui-this">编辑友情链接</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label">所属站点</label>
                        <div class="layui-input-block">
                            <select class="select" name="site_id" url="/webapi/siteJson" selectValue="@Model.site_id" promtion="请选择站点..." datatype="*" errormsg="请选择所属站点！" sucmsg=" "><option value="">请选择站点...</option></select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">标题名称</label>
                        <div class="layui-input-block">@Html.TextBox("title", Model.title, new { @class = "input normal", datatype = "*2-100", sucmsg = " " })</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">审核状态</label>
                        <div class="layui-input-block">
                            @Html.RadioButton("is_lock", 0, Model.is_lock == 0, new { title = "正常" })
                            @Html.RadioButton("is_lock", 1, Model.is_lock == 1, new { title = "待审核" })
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">推荐到首页</label>
                        <div class="layui-input-block">
                            @Html.CheckBox("is_red", Model.is_red == 1, new { title = "是" })
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">排序数字</label>
                        <div class="layui-input-block">
                            @Html.TextBox("sort_id", Model.sort_id, new { @class = "input small", datatype = "n", sucmsg = " " })
                            <span class="Validform_checktip">*数字，越小越向前</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">联系人</label>
                        <div class="layui-input-block">@Html.TextBox("user_name", Model.user_name, new { @class = "input normal", datatype = "*0-50", sucmsg = " " })</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">联系电话</label>
                        <div class="layui-input-block">@Html.TextBox("user_tel", Model.user_tel, new { @class = "input normal", datatype = "*0-30", sucmsg = " " })</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">电子邮箱</label>
                        <div class="layui-input-block">@Html.TextBox("email", Model.email, new { @class = "input normal", datatype = "*0-50", sucmsg = " " })</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">链接网址</label>
                        <div class="layui-input-block">@Html.TextBox("site_url", Model.site_url, new { @class = "input normal", datatype = "url", sucmsg = " " })</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">Logo图片</label>
                        <div class="layui-input-block">
                            @Html.TextBox("img_url", Model.img_url, new { @class = "input normal upload-path" })
                            <div class="upload-box choose-pick"><a href="javascript:;" class="webuploader-pick" title="图片空间">选择图片</a></div>
                            <div class="upload-box upload-cover"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--/内容-->
    <!--工具栏-->
    <div class="page-footer">
        <div class="btn-wrap">
            <button class="layui-btn icon-btn" id="btnSubmit"><i class="layui-icon layui-icon-ok"></i>提交保存</button>
            <button class="layui-btn layui-btn-warm icon-btn" name="btnReturn" onclick="javascript:history.back(-1);"><i class="layui-icon layui-icon-return"></i>返回上一页</button>
        </div>
    </div>
    <!--/工具栏-->
</form>
@section Scripts{
    <script type="text/javascript" src="/scripts/libs/js/uploader.js"></script>
    <script type="text/javascript">
        layui.use(['validform', 'element', 'jqueryform', 'cascadeSelect', 'fileChoose'], function () {
            var cascadeSelect = layui.cascadeSelect, fileChoose = layui.fileChoose;
            cascadeSelect.init('site_id', false);
            $('.choose-pick').click(function () {
                var obj = $(this);
                fileChoose.open({
                    fileUrl: '',
                    listUrl: '/admin_ajax/files',
                    num: 1,
                    dialog: {
                        offset: '60px'
                    },
                    onChoose: function (res) {
                        if (res[0].type != "file") {
                            layer.msg('我只让你选择图片格式的文件', { icon: 2, time: 2000 }, function () { });
                            return;
                        }
                        obj.siblings(".upload-path").val(res[0].url);
                        obj.siblings(".layer-photos").show().find("img").attr("src", res[0].url);
                    }
                });
            });
            //初始化表单验证
            $("#form1").initValidform('#btnSubmit', 1);
            $(".upload-img").InitUploader({ sendurl: "/upload_ajax/action", swf: "/scripts/libs/module/uploader/uploader.swf" });
        });
    </script>
}